<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
        $(function () {
            $("#validForm").validate();
            $("input[name='text']").focus();
        });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1><s:message code="comment.management"/> - <s:message code="${oprt=='edit' ? 'edit' : 'create'}"/></h1>
</div>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="${oprt=='edit' ? 'update' : 'save'}.do" method="post">
            <tags:search_params/>
            <f:hidden name="infoid" value="${infoid}"/>
            <f:hidden name="ftype" value="${ftype}"/>
            <f:hidden name="oid" value="${bean.id}"/>
            <f:hidden name="position" value="${position}"/>
            <input type="hidden" id="redirect" name="redirect" value="edit"/>
            <div class="box-header with-border">
                <div class="btn-toolbar">
                    <div class="btn-group">
                        <button class="btn btn-default" type="button"
                                onclick="location.href='list.do?infoid=${infoid}&ftype=${ftype}&${searchstring}';"
                        ><s:message code="return"/></button>
                    </div>
                </div>
            </div>
            <div class="box-body">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><s:message code="comment.info"/></label>
                            <div class="col-sm-10">
                                <f:text class="form-control" value="${bean.anchor.title}" disabled="disabled"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><s:message code="comment.creator"/></label>
                            <div class="col-sm-8">
                                <f:text class="form-control" value="${bean.creator.username}" disabled="disabled"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required">*</em><s:message
                                    code="comment.creationDate"/></label>
                            <div class="col-sm-8">
                                <input class="form-control required" type="text" name="creationDate"
                                       value="<fmt:formatDate value="${bean.creationDate}" pattern="yyyy-MM-dd'T'HH:mm:ss"/>"
                                       onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required">*</em><s:message
                                    code="comment.status"/></label>
                            <div class="col-sm-8">
                                <select class="form-control" name="status" disabled="disabled">
                                    <f:option value="0" selected="${bean.status}"><s:message
                                            code="comment.status.0"/></f:option>
                                    <f:option value="1" selected="${bean.status}"><s:message
                                            code="comment.status.1"/></f:option>
                                    <f:option value="2" selected="${bean.status}"><s:message
                                            code="comment.status.2"/></f:option>
                                    <f:option value="3" selected="${bean.status}"><s:message
                                            code="comment.status.3"/></f:option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required">*</em><s:message
                                    code="comment.ip"/></label>
                            <div class="col-sm-8">
                                <f:text class="form-control required" name="ip" value="${bean.ip}" disabled="disabled"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><s:message code="comment.country"/></label>
                            <div class="col-sm-8">
                                <f:text name="country" value="${bean.country}" disabled="disabled"
                                        class="form-control required"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><s:message code="comment.area"/></label>
                            <div class="col-sm-8">
                                <f:text name="area" value="${bean.area}" disabled="disabled"
                                        class="form-control required"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6" style="display: none">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><em class="required">*</em><s:message
                                    code="comment.score"/></label>
                            <div class="col-sm-8">
                                <f:text name="score" value="${bean.score}" class="form-control required digits"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label"><s:message code="comment.auditDate"/></label>
                            <div class="col-sm-8">
                                <input class="form-control" type="text" name="auditDate"
                                       value="<fmt:formatDate value="${bean.auditDate}" pattern="yyyy-MM-dd'T'HH:mm:ss"/>"
                                       onclick="WdatePicker({dateFmt:'yyyy-MM-ddTHH:mm:ss'});"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><em class="required">*</em><s:message
                                    code="comment.text"/></label>
                            <div class="col-sm-10">
                                <f:textarea class="form-control" name="text" value="${bean.text}" rows="7"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <button class="btn btn-primary" type="submit"><s:message code="save"/></button>
                <%--<button class="btn btn-default" type="submit" onclick="$('#redirect').val('list');"><s:message--%>
                        <%--code="saveAndReturn"/></button>--%>
                <c:if test="${oprt=='create'}">
                    <button class="btn btn-default" type="submit" onclick="$('#redirect').val('create');"><s:message
                            code="saveAndCreate"/></button>
                </c:if>
            </div>
            </form>
    </div>
</div>
</body>
</html>